#ifndef _BS8116_H_
#define _BS8116_H_



#include "main.h"
#include "tim.h"

#define  BS_SCL_HIGH()     HAL_GPIO_WritePin(GPIOB,BS_SCL_Pin,GPIO_PIN_SET)
#define  BS_SCL_LOW()     HAL_GPIO_WritePin(GPIOB,BS_SCL_Pin,GPIO_PIN_RESET)
#define  BS_SDA_HIGH()     HAL_GPIO_WritePin(GPIOB,BS_SDA_Pin,GPIO_PIN_SET)
#define  BS_SDA_LOW()     HAL_GPIO_WritePin(GPIOB,BS_SDA_Pin,GPIO_PIN_RESET)
#define  IIC1_SDA_IN      HAL_GPIO_ReadPin(GPIOB,BS_SDA_Pin)
#define  IIC1_SCL_IN      HAL_GPIO_ReadPin(GPIOB,BS_SCL_Pin)
#define  BS8116_IRQ       HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_1)

#define BS8116_ADDR_W 0xA0   //10100000
#define BS8116_ADDR_R 0xA1

void IIC1_Config(void);
void IIC1_Start(void);
void IIC1_Stop(void);
void IIC1_Send_Ack(uint8_t ack);
uint8_t IIC1_Revice_Ack(void);
uint8_t IIC1_Send_Byte(uint8_t data);
uint8_t IIC1_Revice_Byte(uint8_t ack);
uint8_t BS8116ReadKey(void);
char Ret_key_value(void);
void my_delay_nus(uint16_t timer);
void my_delay_nms(uint32_t timer);


#endif
